package com.jucai.pppeiyouclient.view.dialog;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;

/**
 * Created by Mars-SC on 2017/6/8.
 */

/**
 * 全屏 显示Dialog
 */
public class FullScreenDialog extends Dialog {
    private int layoutId;
    private OnContentViewListener mListener;
    private Context context;

    private FullScreenDialog(Context context) {
        super(context);
        this.context = context;
    }

    private FullScreenDialog(Context context, int theme) {
        super(context, theme);
        this.context = context;
    }

    public FullScreenDialog(Context context, int theme, int layoutId, OnContentViewListener mListener) {
        super(context, theme);
        this.layoutId = layoutId;
        this.mListener = mListener;
        this.context = context;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        View view = ((Activity)context).getLayoutInflater().inflate(layoutId, null);
        setContentView(view);
        if(mListener != null)
            mListener.OnSetContentView(view);

        getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    }

    public static interface OnContentViewListener {
        public void OnSetContentView(View view);
    }
}
